package com.elite.service;

import com.elite.dao.FileGoodsMapper;
import com.elite.dao.FileMapper;
import com.elite.entity.File;
import com.elite.entity.FileGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/1/22.
 */
@Service("FileService")
public class FileServiceImp implements FileService {

    @Autowired
    private FileMapper fileMapper;
    @Autowired
    private FileGoodsMapper fileGoodsMapper;

    @Override
    public void addFileImg(File file) {
        fileMapper.insert(file);
    }

    @Override
    public void addFileGoods(FileGoods fileGoods) {
        fileGoodsMapper.insert(fileGoods);
    }

    @Override
    public File selectByFileName(String fileName) {
        return fileMapper.selectByFileName(fileName);
    }

    @Override
    public FileGoods selectByUserId(Integer userId) {
        return fileGoodsMapper.selectByUserId(userId);
    }

    @Override
    public List selectByGoodsId(Integer goodsId) {
        return fileGoodsMapper.selectByGoodsId(goodsId);
    }

    @Override
    public File selectByPrimaryKey(Integer fileId) {
        return fileMapper.selectByPrimaryKey(fileId);
    }

    @Override
    public void updateByPrimaryKey(File file) {
        fileMapper.updateByPrimaryKey(file);
    }

    @Override
    public void delete(Integer fileId) {
        fileMapper.deleteByPrimaryKey(fileId);
    }
}
